let lastTime = null
let currentTime = null
const timeOut = 30 * 60 * 1000 * 4 // 设置超时时间: 2个小时
// let timeRunning = null
window.onload = function () {
  //获取鼠标移动事件
  window.document.onmouseover = function () {
    lastTime = currentTime
    currentTime = new Date().getTime() // 更新lastTime
    console.log('鼠标移动')
    checkTimeout()
  }
}
function checkTimeout () {
  // currentTime = new Date().getTime() // 更新当前时间
  if (currentTime - lastTime > timeOut) { // 判断是否超时
    // console.log('已经超时')
    // location. reload()

    // 插入登出记录
    let url = 'http://111.160.78.62:9930/Cityscapeapi/Role/InsertHandleDailyLogout?IP=' + localStorage.getItem('ip') + '&UserName=' + window.localStorage.getItem('LOGIN_NAME')
    console.log(url)
    $.ajax({
      url: url, success: function (result) {
        // console.log(result)
      }
    });

    // 清除缓存
    window.localStorage.clear()
    // 添加关键字
    window.localStorage.setItem('LogoutTimeOut', '1')
    // 清除定时
    // clearInterval(timeRunning)
    // 跳到登陆页
    /* 跳转代码 */
    window.open("http://111.160.78.62:4484/#/login", "_self");
    // this.$router.push({
    //   path: '/login'
    // })
    // this.$message.error('请重新登录')

  } else {
    console.log('执行一次')
    console.log(currentTime)
  }
}
export default function (UserName) {
  console.log('开始监听')
}
